DAY2:String ends with?


Posted by birdbirdmurmur on 2023-07-15

題目連結:

解題過程:

  • 第一個想法是直接用includes(),以為可以輕鬆通過
    • 原以為includes()無法判斷string
      • 有想過要不要先判斷型態
    • 被自己笨死,看錯題目(請好好練英文x
  • 搞懂題目之後,翻開MDN字典
    • 使用endsWith()可快速判斷字串的結尾
      • 可以區分大小寫
  • Done.

解法:

function solution(str, ending){
  return str.endsWith(ending);
}

參考資料:


#javascript #Codewars #endWith







Related Posts

[學學ReactNative] DAY1 - 前言與動機:為何選擇 React Native?

[學學ReactNative] DAY1 - 前言與動機:為何選擇 React Native?

Cache 是什麼?

Cache 是什麼?

webpack 打包工具入門

webpack 打包工具入門


Comments